# Author:sp
# CreaTime: $(DATE)
# FileName: $(NAME)
# Description: simple introdution of the code
'''
Student类实现了特殊方法__enter__()和__exit__()称为该类对象最受上下文管理器协议
该类对象的实例对象，称为上下文管理器
'''
class Student(object):
    def __enter__(self):
        print('调用了__enter__()方法')
        return self
    def __exit__(self, exc_type, exc_val, exc_tb):
        print('调用了__exit__()方法')
    def name(self):
        print('调用了实例方法name')
with Student() as file:
     file.name()